<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="subclassing-reprs.html" />
<link rel="prev" href="module-repr.html" />
<link rel="parent" href="module-repr.html" />
<link rel="next" href="subclassing-reprs.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>5.19.1 Repr Objects </title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="5.19 repr  "
  href="module-repr.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="5.19 repr  "
  href="module-repr.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="5.19.2 subclassing Repr Objects"
  href="subclassing-reprs.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-repr.html">5.19 repr  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-repr.html">5.19 repr  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="subclassing-reprs.html">5.19.2 Subclassing Repr Objects</a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h2><a name="SECTION0071910000000000000000"></a><a name="Repr-objects"></a>
<br>
5.19.1 Repr Objects 
</h2>

<p>
<tt class="class">Repr</tt> instances provide several members which can be used to
provide size limits for the representations of different object types, 
and methods which format specific object types.

<p>
<dl><dt><b><tt id='l2h-917' xml:id='l2h-917' class="member">maxlevel</tt></b></dt>
<dd>
  Depth limit on the creation of recursive representations.  The
  default is <code>6</code>.
</dl>

<p>
<dl><dt><b><tt id='l2h-918' xml:id='l2h-918' class="member">maxdict</tt></b></dt>
<dd>
<dt><b><tt id='l2h-919' xml:id='l2h-919' class="member">maxlist</tt></b></dt><dd><dt><b><tt id='l2h-920' xml:id='l2h-920' class="member">maxtuple</tt></b></dt><dd><dt><b><tt id='l2h-921' xml:id='l2h-921' class="member">maxset</tt></b></dt><dd><dt><b><tt id='l2h-922' xml:id='l2h-922' class="member">maxfrozenset</tt></b></dt><dd><dt><b><tt id='l2h-923' xml:id='l2h-923' class="member">maxdeque</tt></b></dt><dd><dt><b><tt id='l2h-924' xml:id='l2h-924' class="member">maxarray</tt></b></dt><dd>  Limits on the number of entries represented for the named object
  type.  The default is <code>4</code> for <tt class="member">maxdict</tt>, <code>5</code> for
  <tt class="member">maxarray</tt>, and  <code>6</code> for the others.
  
<span class="versionnote">New in version 2.4:
<tt class="member">maxset</tt>, <tt class="member">maxfrozenset</tt>,
  and <tt class="member">set</tt>.</span>
.
</dl>

<p>
<dl><dt><b><tt id='l2h-925' xml:id='l2h-925' class="member">maxlong</tt></b></dt>
<dd>
  Maximum number of characters in the representation for a long
  integer.  Digits are dropped from the middle.  The default is
  <code>40</code>.
</dl>

<p>
<dl><dt><b><tt id='l2h-926' xml:id='l2h-926' class="member">maxstring</tt></b></dt>
<dd>
  Limit on the number of characters in the representation of the
  string.  Note that the ``normal'' representation of the string is
  used as the character source: if escape sequences are needed in the
  representation, these may be mangled when the representation is
  shortened.  The default is <code>30</code>.
</dl>

<p>
<dl><dt><b><tt id='l2h-927' xml:id='l2h-927' class="member">maxother</tt></b></dt>
<dd>
  This limit is used to control the size of object types for which no
  specific formatting method is available on the <tt class="class">Repr</tt> object.
  It is applied in a similar manner as <tt class="member">maxstring</tt>.  The
  default is <code>20</code>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-928' xml:id='l2h-928' class="method">repr</tt></b>(</nobr></td>
  <td><var>obj</var>)</td></tr></table></dt>
<dd>
  The equivalent to the built-in <tt class="function">repr()</tt> that uses the
  formatting imposed by the instance.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-929' xml:id='l2h-929' class="method">repr1</tt></b>(</nobr></td>
  <td><var>obj, level</var>)</td></tr></table></dt>
<dd>
  Recursive implementation used by <tt class="method">repr()</tt>.  This uses the
  type of <var>obj</var> to determine which formatting method to call,
  passing it <var>obj</var> and <var>level</var>.  The type-specific methods
  should call <tt class="method">repr1()</tt> to perform recursive formatting, with
  <code><var>level</var> - 1</code> for the value of <var>level</var> in the recursive 
  call.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b>repr_<var>type</var></b>(</nobr></td>
  <td><var>obj, level</var>)</td></tr></table></dt>
<dd>
  Formatting methods for specific types are implemented as methods
  with a name based on the type name.  In the method name, <var>type</var>
  is replaced by
  <code>string.join(string.split(type(<var>obj</var>).__name__, '_'))</code>.
  Dispatch to these methods is handled by <tt class="method">repr1()</tt>.
  Type-specific methods which need to recursively format a value
  should call "<tt class="samp">self.repr1(<var>subobj</var>, <var>level</var> - 1)</tt>".
</dl>

<p>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="5.19 repr  "
  href="module-repr.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="5.19 repr  "
  href="module-repr.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="5.19.2 subclassing Repr Objects"
  href="subclassing-reprs.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-repr.html">5.19 repr  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-repr.html">5.19 repr  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="subclassing-reprs.html">5.19.2 Subclassing Repr Objects</a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
